#ifndef __SUBSYSTEM_MAGMA_BLOCK_BEHAVIOR_H__
#define __SUBSYSTEM_MAGMA_BLOCK_BEHAVIOR_H__

#include "SubsystemFluidBlockBehavior.h"

namespace PocketSurvival
{
    class SubsystemTimeOfDay;
    class SubsystemFireBlockBehavior;
    class SubsystemTerrain;

    // 岩浆行为，包括扩散，着火，和将水变成玄武岩
    class SubsystemMagmaBlockBehavior : public SubsystemFluidBlockBehavior
    {
    protected:
        SubsystemTimeOfDay *m_timeOfDay;
        SubsystemFireBlockBehavior *m_fireBlockBehavior;
        SubsystemTerrain *m_terrain;

    public:
        virtual bool onFluidInteract(int32_t interactValue, int32_t x, int32_t y, int32_t z, int32_t fluidValue) override;
        virtual void onBlockAdded(int32_t value, int32_t oldValue, int32_t x, int32_t y, int32_t z) override;
        virtual void onNeighborBlockChanged(int32_t x, int32_t y, int32_t z, int32_t neighborX, int32_t neighborY, int32_t neighborZ) override;

        void applyMagmaNeighborhoodEffect(int32_t x, int32_t y, int32_t z);

    public:
        SubsystemMagmaBlockBehavior();

        virtual void update(float dt) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;
        virtual void load(const nlohmann::json& json) override;

        virtual const std::string& getName() const override;
        virtual SubUpdateType getUpdateType() override;

    };
}

#endif